package com.server.controller;

import com.server.model.AcceptedSocketThread;

import java.util.HashMap;
import java.util.Iterator;

/**
 *
 */
public class AcceptedSocketThreadManager {
    public static HashMap map= new HashMap<String, AcceptedSocketThread>();

    //向hm中添加一个客户端通讯线程
    public static void addClient(String uid, AcceptedSocketThread ct){
        map.put(uid,ct);
    }

    public static AcceptedSocketThread getClientThread(String uid){
        return (AcceptedSocketThread)map.get(uid);
    }

    public static void remove(String uid){
        map.remove(uid);
    }
    public static void removeAll(){
        map.clear();
    }
    //返回当前在线的人的情况
    public static String getAllOnlineUserId(){
        String res="";
        Iterator it = map.keySet().iterator();
        while (it.hasNext()){
            res+=it.next()+" ";
        }
        return res;
    }
}
